package com.xyw.his00.dto;

import com.xyw.his00.pojo.dbpojo.InspectionRequest;
import com.xyw.his00.pojo.dbpojo.InspectionRequest;
import lombok.Data;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Data
public class InspectionRequestDTO {
    private Integer id;
    private Integer registerId;
    private Integer medicalTechnologyId;
    private String inspectionInfo;
    private String inspectionPosition;
    private String creationTime;
    private Integer inspectionEmployeeId;
    private Integer inputinspectionEmployeeId;
    private String inspectionTime;
    private String inspectionResult;
    private String inspectionState;//状态
    private String inspectionRemark;
    public static InspectionRequest revert(InspectionRequestDTO inspectionRequest)throws NullPointerException{
        return  new InspectionRequest(inspectionRequest.getId(),
                inspectionRequest.getRegisterId(),
                inspectionRequest.getMedicalTechnologyId(),
                inspectionRequest.getInspectionInfo(),
                inspectionRequest.getInspectionPosition(),
                inspectionRequest.getCreationTime()==null?null:  LocalDateTime.parse(inspectionRequest.getCreationTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")),
                inspectionRequest.getInspectionEmployeeId(),
                inspectionRequest.getInputinspectionEmployeeId(),
                inspectionRequest.getInspectionTime()==null?null:  LocalDateTime.parse(inspectionRequest.getInspectionTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")),
                inspectionRequest.getInspectionResult(),
                inspectionRequest.getInspectionState(),
                inspectionRequest.getInspectionRemark());
    }
    public static InspectionRequest[] revert(InspectionRequestDTO[] inspectionRequests){
        if (inspectionRequests == null) {
            return null;
        }
        InspectionRequest[] inspections = new InspectionRequest[inspectionRequests.length];
        for (int i = 0; i < inspectionRequests.length; i++) {
            inspections[i] = revert(inspectionRequests[i]);
        }
        return inspections;
    }
}
